<template>
	<view class="">
		<view class="bg_flow_img">

		</view>
		<view class="flow_header" :style="{marginTop: systemBarHeight + 'px'}">
			<view class="flow_header_font">
				账单流水
			</view>
			<view class="" style="flex: 1;">

			</view>
			<image src="../static/search_black.png" mode="" style="width: 48rpx;height: 48rpx;" />
		</view>
		<view class="shaixuan_flow">
			<view class="shaixuan_flow_item">
				<view class="shaixuan_flow_item_font">
					时间
				</view>
				<image src="../static/select_bottom_flow.png" style="width: 24rpx;height: 24rpx;" />
			</view>
			<view class="shaixuan_flow_item">
				<view class="shaixuan_flow_item_font">
					分类
				</view>
				<image src="../static/select_bottom_flow.png" style="width: 24rpx;height: 24rpx;" />
			</view>
			<view class="shaixuan_flow_item">
				<view class="shaixuan_flow_item_font">
					账户
				</view>
				<image src="../static/select_bottom_flow.png" style="width: 24rpx;height: 24rpx;" />
			</view>
			<view class="shaixuan_flow_item">
				<view class="shaixuan_flow_item_font">
					状态
				</view>
				<image src="../static/select_bottom_flow.png" style="width: 24rpx;height: 24rpx;" />
			</view>
		</view>

		<view class="flows_lists">
			<view class="flows_lists_item" v-for="item in datas" @click="dataClick(item)">
				<view class="date_flow_data_font_and_price">
					<view class="date_flow_data_font">
						{{buildTimeStr(item['tally_time'])}}
					</view>
					<view class="date_flow_data_price" v-if="item['type'] == 10">
						+{{item['amount']}}
					</view>
					<view class="date_flow_data_price" v-else-if="item['type'] == 20" style="color: #F4C241;">
						-{{item['amount']}}
					</view>
					<view class="date_flow_data_price" style="color: rgba(137, 217, 188, 1);" v-else>
						{{item['amount']}}
					</view>
				</view>
				<view class="data_cate_account">
					<view class="data_cate_font">
						{{categoRyText(item)}}
					</view>
					<view class="data_account_font">
						{{accountTextTypeStr(item)}}
					</view>
				</view>
			</view>
		</view>

		<view class="" style="height: 30rpx;">

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				systemBarHeight: 0,
				datas: []
			}
		},
		computed: {
			tally() {
				return this.$store.state.tally;
			}
		},
		onLoad() {
			this.getSysteminfo()
			this.get_flows()
			console.log(this.$store.state.tally)
		},
		methods: {
			buildTimeStr(string) {
				return string.split(' ')[0]
			},
			categoRyText(e) {
				if (e['type'] != 30) {
					return e['type_txt']+'->'+e['category_name'];
				} else {
					return e['type_txt'];
				}
			},
			accountTextTypeStr(e){
				if (e['type'] != 30) {
					return e['account_name'];
				} else {
					return e['account_name']+'->'+e['account_dst_name'];
				}
			},
			dataClick(item) {
				console.log(item)
			},
			async get_flows() {
				this.$commonUtils.showLoading()
				let params = {
					page: 1,
					tally_id: this.tally['id']
				};
				let resultData = await this.$api.common.get_flows({
					data: params
				})
				this.datas = resultData['data']['data'];
				this.$commonUtils.hideLoading()
			},
			getSysteminfo() {
				uni.getSystemInfo({
					success: res => {
						this.systemBarHeight = res.statusBarHeight;
					}
				});
			}
		}
	}
</script>

<style>
	.bg_flow_img {
		background-image: url("https://static.gongsizhang.com/2024-05-20-664b70e38827d.png");
		background-size: 100% 100%;
		background-repeat: no-repeat;
		width: 750rpx;
		height: 320rpx;
		position: fixed;
		z-index: -99;
		top: 0;
	}

	.shaixuan_flow_item_font {
		width: 80rpx;
		text-overflow: ellipsis;
		color: #666666;
		font-size: 32rpx;
	}

	.shaixuan_flow {
		width: 750rpx;
		height: 88rpx;
		display: flex;
		margin: 0 auto;
	}

	.shaixuan_flow_item {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.data_cate_font {
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}

	.data_account_font {
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
		text-align: right;
		font-style: normal;
		text-transform: none;
	}

	.data_cate_account {
		display: flex;
		justify-content: space-between;
	}

	.date_flow_data_font_and_price {
		display: flex;
		justify-content: space-between;
		font-weight: 500;
		font-size: 40rpx;
		color: #4185F4;
		text-align: right;
		font-style: normal;
		text-transform: none;
	}

	.date_flow_data_font {
		font-family: PingFang SC, PingFang SC;
		font-size: 34rpx;
		color: #333333;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}

	.flows_lists_item {
		width: 636rpx;

		height: 128rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		padding: 24rpx;
		border-bottom: 1rpx dashed #CCCCCC;
	}

	.flows_lists {
		width: 686rpx;
		margin: 0 auto;
	}

	.flow_header {
		display: flex;
		align-items: center;
		padding-left: 46rpx;
		padding-right: 32rpx;
		padding-top: 24rpx;
		padding-bottom: 10rpx;
		margin: 0 auto;
	}

	.flow_header_font {
		font-size: 48rpx;
		color: #666666;
		font-weight: 500;
	}
</style>